/**
 * 连接redis
 */

'use strict';

var config = require('../config/config.js');
var redis = require('redis');
var redisLua2 = require('redis-lua2');
var coRedis = require('co-redis');

redisLua2.attachLua(redis);
var client = redis.createClient(config.redis.port, config.redis.host);
var redisCo = coRedis(client);

module.exports = {
	redisCo: redisCo,
	redis: redis,
	client: client
};

client.on('error', function(err) {
	throw err;
});

// load lua script